package com.ruiyian.web.controller.secondaryaccident;

import com.ruiyian.common.core.controller.BaseController;
import com.ruiyian.common.core.domain.AjaxResult;
import com.ruiyian.common.core.page.TableDataInfo;
import com.ruiyian.system.domain.JnCameraInfo;
import com.ruiyian.system.service.IJnCameraInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/camerainfo")
public class JnCameraInfoController extends BaseController {
    @Autowired
    private IJnCameraInfoService jnCameraInfoService;

    /**
     * 查询摄像头信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(JnCameraInfo jnCameraInfo)
    {
        startPage();
        List<JnCameraInfo> list = jnCameraInfoService.selectJnCameraInfoList(jnCameraInfo);
        return getDataTable(list);
    }

    /**
     * 获取摄像头详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        AjaxResult ajax = AjaxResult.success(jnCameraInfoService.selectJnCameraInfoById(id));
        return ajax;
    }

    /**
     * 新增摄像头
     */
    @PostMapping
    public AjaxResult add(@RequestBody JnCameraInfo jnCameraInfo)
    {
        return toAjax(jnCameraInfoService.insertJnCameraInfo(jnCameraInfo));
    }

    /**
     * 修改摄像头信息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody JnCameraInfo jnCameraInfo)
    {
        return toAjax(jnCameraInfoService.updateJnCameraInfo(jnCameraInfo));
    }

    /**
     * 删除【请填写功能名称】
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jnCameraInfoService.deleteJnCameraInfoByIds(ids));
    }
}
